{{ if and .Site.Params.enableMinimalFooter (in .Site.Params.mainSections .Section) }}
    <footer class="minimal-footer">
        {{ with .Params.tags }}
            {{ $length := sub (len .) 1 }}
            <div class="post-tag">
                {{- range $index, $tag := . -}}
                    {{- $url := urls.Parse ($tag | urlize) -}}
                    {{- $path := $url.Path -}}
                    {{- with $.Site.GetPage (printf `/tags/%s` $path) -}}
                        <a href="{{ .RelPermalink }}" rel="tag" class="post-tag-link">#{{ .Slug | default .LinkTitle | default $tag | lower | anchorize }}</a>
                        {{- if lt $index $length -}}
                            {{- print " " -}}
                        {{- end -}}
                    {{- end -}}
                {{- end -}}
            </div>
        {{ end }}
        {{ if eq .Site.Params.categoryBy "sections" }}
            <div class="post-category">
                {{ if .Site.Params.enableVerticalBarStructure }}
                    {{- with .Site.GetPage .Section -}}
                        <a href="{{ .RelPermalink }}" class="post-category-link active">{{ .Slug | default .Params.url | default .LinkTitle | default $.Section | lower | anchorize }}</a>
                    {{- end -}}
                    {{- if gt (len .Site.Params.mainSections) 1 -}}
                        {{- printf `%s` " | " | safeHTML -}}
                        {{- $sections := (.Site.Params.mainSections | symdiff (slice .Section)) -}}
                        {{- $length := sub (len $sections) 1 -}}
                        {{- range $index, $section := $sections -}}
                            {{- with $.Site.GetPage $section -}}
                                <a href="{{ .RelPermalink }}" class="post-category-link">{{ .Slug | default .Params.url | default .LinkTitle | default $section | lower | anchorize }}</a>
                                {{- if lt $index $length -}}
                                    {{- printf `%s` " | " | safeHTML -}}
                                {{- end -}}
                            {{- end -}}
                        {{- end -}}
                    {{- end -}}
                {{ else }}
                    {{ $sections := split (strings.TrimSuffix "/" ($.File.Dir | default $.Section)) "/" }}
                    {{ with $sections }}
                        {{ $.Scratch.Delete "sectionsDirMeta" }}
                        {{ $.Scratch.Delete "sectionsMeta" }}
                        {{ $.Scratch.Set "index" 0 }}
                        {{ range $sections }}
                            {{ $section := . }}
                            {{ $.Scratch.Add "sectionsDirMeta" (printf `/%s` $section) }}
                            {{ with $.Site.GetPage ($.Scratch.Get "sectionsDirMeta") }}
                                {{ if (eq .Kind "section") }}
                                    {{ $.Scratch.SetInMap "sectionsMeta" (printf `%s/%s` (string ($.Scratch.Get "index")) .RelPermalink) (.Slug | default .Params.url | default .LinkTitle | default $section | lower | anchorize) }}
                                    {{ $.Scratch.Set "index" (add ($.Scratch.Get "index") 1) }}
                                {{ end }}
                            {{ end }}
                        {{ end }}
                    {{ end }}
                    {{ $sections := .Scratch.Get "sectionsMeta" }}
                    {{ with $sections }}
                        {{ $length := (sub (len $sections) 1) }}
                        {{- range $link, $title := $sections -}}
                            {{- $index := $link | replaceRE `(\d+)/.+` `$1` | int -}}
                            {{- if lt $index $length -}}
                                {{- $.Scratch.Set "delimiter" ($.Site.Params.categoryDelimiter | default "/") -}}
                            {{- else -}}
                                {{- $.Scratch.Set "delimiter" "" -}}
                            {{- end -}}
                            {{- $delimiter := ($.Scratch.Get "delimiter") -}}
                            {{- printf `<a href="%s" class="post-category-link">%s</a>%s` ($link | replaceRE `\d+/(.+)` `$1`) ($title | lower) $delimiter | safeHTML -}}
                        {{- end -}}
                    {{ end }}
                {{ end }}
            </div>
        {{ end }}
        {{ if eq .Site.Params.categoryBy "categories" }}
            {{ with .Params.categories }}
                <div class="post-category">
                    {{ if $.Site.Params.enableVerticalBarStructure }}
                        {{- $currentTopLevelCategory := (delimit (first 1 .) " ") -}}
                        {{- $url := urls.Parse ($currentTopLevelCategory | urlize) -}}
                        {{- $path := $url.Path -}}
                        {{- with $.Site.GetPage (printf `/categories/%s` $path) -}}
                            <a href="{{ .RelPermalink }}" class="post-category-link active">{{ .Slug | default .LinkTitle | default $path | lower | anchorize }}</a>
                        {{- end -}}
                        {{- $.Scratch.Delete "topLevelCategories" -}}
                        {{- range $.Site.RegularPages -}}
                            {{- with .Param "categories" -}}
                                {{- $topLevelCategory := ((delimit (first 1 .) " ") | urlize) -}}
                                {{- $.Scratch.Add "topLevelCategories" (slice $topLevelCategory) -}}
                            {{- end -}}
                        {{- end -}}
                        {{- $categories := uniq ($.Scratch.Get "topLevelCategories") -}}
                        {{- if gt (len $categories) 1 -}}
                            {{- printf `%s` " | " | safeHTML -}}
                            {{- $categories := ($categories | symdiff (slice ($currentTopLevelCategory | urlize))) -}}
                            {{- $length := sub (len $categories) 1 -}}
                            {{- range $index, $category := $categories -}}
                                {{- $category := urls.Parse $category -}}
                                {{- $path := $category.Path -}}
                                {{- with $.Site.GetPage (printf `/categories/%s` $path) -}}
                                    <a href="{{ .RelPermalink }}" class="post-category-link">{{ .Slug | default .LinkTitle | default $path | lower | anchorize }}</a>
                                    {{- if lt $index $length -}}
                                        {{- printf `%s` " | " | safeHTML -}}
                                    {{- end -}}
                                {{- end -}}
                            {{- end -}}
                        {{- end -}}
                    {{ else }}
                        {{ $length := sub (len .) 1 }}
                        {{- range $index, $category := . -}}
                            {{- if lt $index $length -}}
                                {{- $.Scratch.Set "delimiter" ($.Site.Params.categoryDelimiter | default "/") -}}
                            {{- else -}}
                                {{- $.Scratch.Set "delimiter" "" -}}
                            {{- end -}}
                            {{- $delimiter := ($.Scratch.Get "delimiter") -}}
                            {{- $url := urls.Parse ($category | urlize) -}}
                            {{- $path := $url.Path -}}
                            {{- with $.Site.GetPage (printf `/categories/%s` $path) -}}
                                {{- printf `<a href="%s" class="post-category-link">%s</a>%s` .RelPermalink (.Slug | default .LinkTitle | default $category | lower | anchorize) $delimiter | safeHTML -}}
                            {{- end -}}
                        {{- end -}}
                    {{ end }}
                </div>
            {{ end }}
        {{ end }}
    </footer>
{{ end }}